/*
 * Copyright (C) 2015 yixun All Rights Reserved.
 * 
 * SaleStatusEnum.java
 */
package com.yixun.qfbao.xf.model.enums;

import com.yixun.common.utils.EnumUtil;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;

/**
 * [文件名称]<br>
 * PremisesDynamic.java<br>
 * <br>
 * [文件描述]<br>
 * 楼盘动态 pojo bean<br>
 * <br>
 * [修改记录]<br>
 * 2015-10-14 15:34:13 创建 陶俊代码生成器<br>
 * 
 * @author 陶俊代码生成器
 * @version 1.00
 */
public enum SaleStatusEnum implements Serializable {
	type_0("0", "待售", null), type_1("1", "在售", null), type_2("2", "售罄", null),type_3("3", "下架", null),;

	private final String no;
	private final String des;
	private final Enum parent;

	static {
		EnumUtil.ENUMS_TO_VIEW.put("sale_status", SaleStatusEnum.values());
	}

	/**
	 * 私有构造函数
	 * 
	 * @param des
	 * @param parent
	 */
	SaleStatusEnum(String no, String des, Enum parent) {
		this.no = no;
		this.des = des;
		this.parent = parent;
	}

	/**
	 * @return Returns the no.
	 */
	public String getNo() {
		return no;
	}

	/**
	 * @return Returns the des.
	 */
	public String getDes() {
		return des;
	}

	/**
	 * @return Returns the parent.
	 */
	public Enum getParent() {
		return parent;
	}

	/**
	 * 通过枚举<code>des</code>获得枚举
	 * 
	 * @param des
	 * @return
	 */
	public static SaleStatusEnum getByDescription(String des) {
		if (StringUtils.isBlank(des)) {
			return null;
		}
		for (SaleStatusEnum menum : values()) {
			if (menum.getDes().equals(des)) {
				return menum;
			}
		}
		return null;
	}

	public static SaleStatusEnum getByNo(String no) {
		if (StringUtils.isBlank(no)) {
			return null;
		}
		for (SaleStatusEnum menum : values()) {
			if (menum.getNo().equals(no)) {
				return menum;
			}
		}
		return null;
	}

	public static String getSalesByNo(String no) {
		if (!StringUtils.isEmpty(no)) {
			SaleStatusEnum sales = getByNo(no);
			if (sales != null) {
				return sales.getDes();
			}
		}
		return null;
	}
}
